<?php

/**
 * This is the model class for table "advertising_cost".
 *
 * The followings are the available columns in table 'advertising_cost':
 * @property integer $id
 * @property string $loginid
 * @property string $amount
 * @property string $pay_date
 * @property string $pay_method
 * @property string $pay_ref
 * @property string $note
 * @property string $check_clear
 * @property string $adddate
 * @property string $ip
 * @property integer $usertype
 * @property string $client_note
 * @property string $memberlist
 * @property string $payableto
 */
class Payment extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @return Payment the static model class
     */
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'advertising_cost';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('loginid', 'required'),
            array('usertype', 'numerical', 'integerOnly'=>true),
            array('loginid', 'length', 'max'=>40),
            array('amount', 'length', 'max'=>8),
            array('pay_method', 'length', 'max'=>3),
            array('pay_ref', 'length', 'max'=>100),
            array('check_clear', 'length', 'max'=>1),
            array('ip', 'length', 'max'=>20),
            array('payableto', 'length', 'max'=>120),
            array('pay_date, adddate, note, client_note, memberlist, orderlist', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, loginid, amount, pay_date, pay_method, pay_ref, note, check_clear, adddate, ip, usertype, client_note, memberlist, payableto', 'safe', 'on'=>'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'loginid' => 'Loginid',
            'amount' => 'Amount',
            'pay_date' => 'Pay Date',
            'pay_method' => 'Pay Method',
            'pay_ref' => 'Pay Ref',
            'note' => 'Note',
            'check_clear' => 'Check Clear',
            'adddate' => 'Adddate',
            'ip' => 'Ip',
            'usertype' => 'Usertype',
            'client_note' => 'Client Note',
            'memberlist' => 'Member List',
        	'orderlist' => 'Order List',
            'payableto' => 'Payableto',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('id',$this->id);
        $criteria->compare('loginid',$this->loginid,true);
        $criteria->compare('amount',$this->amount,true);
        $criteria->compare('pay_date',$this->pay_date,true);
        $criteria->compare('pay_method',$this->pay_method,true);
        $criteria->compare('pay_ref',$this->pay_ref,true);
        $criteria->compare('note',$this->note,true);
        $criteria->compare('check_clear',$this->check_clear,true);
        $criteria->compare('adddate',$this->adddate,true);
        $criteria->compare('ip',$this->ip,true);
        $criteria->compare('usertype',$this->usertype);
        $criteria->compare('client_note',$this->client_note,true);
        $criteria->compare('memberlist',$this->memberlist,true);
        $criteria->compare('orderlist',$this->orderlist,true);
        $criteria->compare('payableto',$this->payableto,true);

        return new CActiveDataProvider($this, array(
            'criteria'=>$criteria,
        ));
    }
} 
